/**********************************************************

     文件名称: quier_cashier.c

     项目功能: 

     作者: 佳奇

     邮箱: 1374804492@qq.com 

     创建时间: Thu 25 Aug 2022 11:27:30 PM CST

**********************************************************/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sup_mgr.h"


// 通过姓名查询员工信息(支持模糊查询)
void quier_cas(cas_list* demo)
{
	char name[31];
	int cnt = 0;
	cas_list* s1 = demo;

	system("clear");
	while(1)
	{
		demo = demo->next;

		printf("请输入需要查询的员工姓名:");
		scanf("%30s", name);
		c_buffer();

		while(demo != NULL)
		{
			if(strstr(demo->data->name, name) != NULL)
			{
				printf("\n工号：%d", demo->data->user);
				printf("\n姓名：%s", demo->data->name);
				printf("\n性别：%s", demo->data->sex == '1' ? "男" : "女");
				printf("\n电话：%s", demo->data->phone);
				printf("\n住址：%s", demo->data->add);
				printf("\n身份证号：%s", demo->data->id);
				cnt++;
				printf("\n第 %d 位员工信息\n", cnt);
			}

			demo = demo->next;
		}


		if(!cnt)
		{
			printf("\n未查询到 %s 的员工信息\n", name);
			printf("是否继续查询(y/n):");
			if(getchar() != 'y')
			{
				c_buffer();
				return;
			}
			else
			{
				c_buffer();
				demo = s1;
				continue;
			}
		}
		else
		{
			printf("\n成功查询到 %d 位收银员信息\n", cnt);
			printf("是否继续查询(y/n):");
			if(getchar() != 'y')
			{
				c_buffer();
				return;
			}
			else
			{
				c_buffer();
				cnt = 0;
				demo = s1;
				system("clear");
				continue;
			}
		}


	}

}


//	收银员个人信息
void q_cas(cas_list* demo, int id)
{
	system("clear");
	printf("\n********您的个人信息如下********\n");

	demo = demo->next;
	while(demo != NULL)
	{
		if(demo->data->user == id)
		{
			printf("\n工号：%d", demo->data->user);
			printf("\n姓名：%s", demo->data->name);
			printf("\n性别：%s", demo->data->sex == '1' ? "男" : "女");
			printf("\n电话：%s", demo->data->phone);
			printf("\n住址：%s", demo->data->add);
			printf("\n身份证号：%s", demo->data->id);
		}

		demo = demo->next;
	}
	printf("\n\n查询完毕按任意键返回上一级菜单:");
	c_buffer();
	getchar();
}


//	收银员销售额
void q_s_e(sales_list* demo, int id)
{
	int rmb = 0;
	char name[31];
	demo = demo->next;
	system("clear");
	printf("\n********您的总销售额如下********\n");
	
	if(demo == NULL)
	{
		printf("\n您暂时还没有卖出过东西呢 继续加油哦！\n");
		printf("\n按任意键返回:");
		getchar();
		c_buffer();
		return;
	}

	while(demo != NULL)
	{
		if(demo->data->id == id)
		{
			strcpy(name, demo->data->name);
			rmb += demo->data->total;
		}

		demo = demo->next;
	}

	printf("\n%s 您的总销售额为 %d 元\n", name, rmb);
	printf("\n查询完毕 按任意键返回上一级菜单:");
	getchar();
	c_buffer();

}


//	收银员销售记录
void q_s_j(sales_list* demo, int id)
{
	system("clear");
	printf("\n******您的销售记录如下******\n");

	if(demo->next == NULL)
	{
		printf("\n您暂时还没有卖出过东西呢 继续加油哦！\n");
		printf("\n按任意键返回:");
		getchar();
		c_buffer();
		return;
	}

	demo = demo->next;

	while(demo != NULL)
	{
		if(demo->data->id == id)
		{
			printf("\n收银员姓名:%s   商品条码:%d   卖出时间:%d年%d月%d日 %d:%2d   商品总价:%d   备注:%s   ", demo->data->name, demo->data->bar, pt->tm_year + 1900, pt->tm_mon + 1, pt->tm_mday, pt->tm_hour, pt->tm_min, demo->data->total, demo->data->note);

			printf("\n");
		}

		demo = demo->next;
	}

	printf("\n查询完毕 按任意键返回上一级菜单:");
	getchar();
	c_buffer();
}










